<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.jieSuan.zhiFuDan"/><spring:message code="message.jieSuan.fuShen"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1><spring:message code="message.jieSuan.zhiFuDan"/><spring:message code="message.jieSuan.fuShen"/></h1>
       <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.jieSuan.zhiFuDanGuanLi"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.jieSuan.zhiFuDan"/><spring:message code="message.jieSuan.fuShen"/></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success ">
            <form  class="form-horizontal" id="form"  method="post" >
            	<div class="box-body">
                    <div class="form-group form-group-xs">
                        <label for="techPos" class="col-sm-2 text-right"><spring:message code="message.jieSuan.zhiFuDan"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            ${setPayment.paymentBillCode}
                        </div>
                        <label for="techPosCertNo" class="col-sm-2 text-right"><spring:message code="message.jieSuan.zhiFuDan"/><spring:message code="message.listForm.mingCheng"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
			              	  ${setPayment.paymentBillName}
                        </div>
                    </div> 
                    
                    <div class="form-group form-group-xs">
                    	<label for="position" class="col-sm-2 text-right"><spring:message code="message.jieSuan.zongTiaoMuShu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
	                 		   ${setPayment.totalOrders}
                        </div>
                        <label for="industry" class="col-sm-2 text-right"><spring:message code="message.jieSuan.zongJinE"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            ${setPayment.totalAmountStr}
                        </div>
                    </div>
                 
                    <div class="form-group form-group-xs">
                          <label for="industry" class="col-sm-2 text-right"><spring:message code="message.lable.remark"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                           ${setPayment.remark}
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                    	<label for="position" class="col-sm-2 text-right"><spring:message code="message.jieSuan.auditPeople"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
	                 		   ${setPayment.auditUser}
                        </div>
                        <label for="industry" class="col-sm-2 text-right"><spring:message code="message.jieSuan.auditTime"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            ${setPayment.auditDatetimeStr}
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="industry" class="col-sm-2 text-right"><spring:message code="message.listForm.shenHeBeiZhu"/><spring:message code="message.yanZheng.maoHao"/></label>
                       <div class="col-sm-10">
	                            ${setPayment.auditRemark}
	                        </div>
                    </div>
                     <div class="form-group form-group-xs">
                        <label for="industry" class="col-sm-2 text-right"><spring:message code="message.jieSuan.fuShen"/><spring:message code="message.lable.remark"/><spring:message code="message.yanZheng.maoHao"/></label>
                       <div class="col-sm-10">
	                            <textarea class="form-control" rows="3" id="auditRemark"  name="auditRemark"  placeholder="<spring:message code="message.jieSuan.fuShen"/><spring:message code="message.lable.remark"/>" ></textarea>
	                        </div>
                    </div>
                </div>
            </form>
        </div>
          <table class="jqgrid" id="gridlist"></table>
		        <div id="gridpage"></div>
		        <div class=" box box-warning bottongroup">
          		    <button type="button" class="btn btn-success btn-sm pass" ><spring:message code="message.listForm.tongGuoSpacing"/></button>
                    <button type="button" class="btn btn-success btn-sm unpass"><spring:message code="message.listForm.buTongGuo"/></button>
                    <a href="toRecheckPaymentList.html" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
                </div>
                
                <form action="${ctx}/nextCheckPayment/toCenterRecheckSetmentDetailList.html" method="post" id="settlementFrom">
                <input type="hidden" id="settlementId" name="settlementId">
                <input type="hidden" id="paymentBillId" name="paymentBillId" value="${setPayment.paymentBillId }">
                </form>
    </section>
	<%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
    function validate() {
   		var auditRemark = $.trim($("#auditRemark").val());
		if(auditRemark.length>512){
			$.HN.message.alert("<spring:message code="message.jieSuan.fuShen"/><spring:message code="message.lable.remark"/><spring:message code="message.info.zuiDaChangDu"/>512<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "<spring:message code="message.HN.alert.type"/>", "warn");
            return false;
		}
		return true;
	}
    	 $(function(){
    	    	$('.pass').click(function(){
    	    		if (!validate()) {return;}
    	    		 $.HN.message.confirm('<spring:message code="message.jieSuan.queDingTongGuoAudit"/>', '', '').on(function (e) {
                         if (e) {
    	               	  $.post('checkPaymentBill.html', {paymentBillId: "${setPayment.paymentBillId}",auditRemark:$('#auditRemark').val(),status:4},
    	               		function (result) {
    		               			if (result) {
    		               				$.HN.message.alert("<spring:message code="message.HN.alert.success"/>", "<spring:message code="message.HN.alert.type"/>", "success", function() {
    		           						document.location = "${ctx}/nextCheckPayment/toRecheckPaymentList.html";
    		           					});
    		           				} else {
    		           					$.HN.message.alert(result.msg || "<spring:message code="message.HN.alert.fail"/>", "<spring:message code="message.HN.alert.type"/>", "error");
    		           				}
    	              			}, "json");
    	                }
    	   	     });
    	       });
    	   	$('.unpass').click(function(){
    	   		if (!validate()) {return;}
    	   	 $.HN.message.confirm('<spring:message code="message.jieSuan.queDingBuTongGuoAudit"/>', '', '').on(function (e) {
                 if (e) {
    	            	   if($('#auditRemark').val() == ""){
    	            		   $.HN.message.alert("<spring:message code="message.jieSuan.fuShen"/><spring:message code="message.lable.remark"/><spring:message code="message.yanZheng.buNengWeiKong"/>", "<spring:message code="message.HN.alert.tiShiXinXi"/>", "info");
    	            		   return;
    	            	   }
    	                $.post('checkPaymentBill.html', {paymentBillId: "${setPayment.paymentBillId}",auditRemark:$('#auditRemark').val(),status:5}, 
    	               		 function (result) {
    			         			if (result) {
    			    					$.HN.message.alert("<spring:message code="message.HN.alert.success"/>", "<spring:message code="message.HN.alert.type"/>", "success", function() {
    			    						document.location = "${ctx}/nextCheckPayment/toRecheckPaymentList.html";
    			    					});
    			    				} else {
    			    					$.HN.message.alert(result.msg || "<spring:message code="message.HN.alert.fail"/>", "<spring:message code="message.HN.alert.type"/>", "error");
    			    				}
    	       		}, "json");
    	               }
    	  	     });
    	      });
    	    	
    	
		$("#gridlist").jqGrid(
				{   url : "getRecheckCenterSetPaymentDetailListData.html",
					mtype : "POST",
					datatype : "json",
					postData : {"paymentBillId" : "${setPayment.paymentBillId}"},
					autowidth : true,
					height : 270,
					colNames : [ 
					            '<spring:message code="message.jqGrid.cz"/>',
                                '<spring:message code="message.jieSuan.jieSuanDan"/>ID',
                                '<spring:message code="message.jieSuan.jieSuanDan"/><spring:message code="message.yanZheng.bianMa"/>',
                                '<spring:message code="message.jieSuan.jieSuanDan"/><spring:message code="message.listForm.mingCheng"/>',
                                '<spring:message code="message.jieSuan.zongTiaoMuShu"/>',
                                '<spring:message code="message.jieSuan.zongJinE"/>',
                                '<spring:message code="message.jieSuan.tiJiaoRen"/>',
                                '<spring:message code="message.jieSuan.tiJiaoShiJian"/>'
					             
					             ],
					colModel : [
								{name : 'operate',index : 'operate',width : 80,align : "center",sortable:false,
								    formatter:function(cellvalue, options, row){
								        var str = "";
								        str += "<a href='javascript:detail(\""+row.settlementId+"\")'><spring:message code="message.jqGrid.cz.xiangQing"/></a>";
								        return str;
								    }
								},
								{name : 'settlementId',index : 'settlementId', hidden : true,width : 160,align : "center",sortable:false},
								{name : 'settlementCode',index : 'settlementCode', width : 160,align : "center",sortable:false},
								{name : 'settlementName',index : 'settlementName', width : 160,align : "center",sortable:false},
								{name : 'totalOrders',index : 'totalOrders', width : 100,align : "center",sortable:false},
								{name : 'totalAmount',index : 'totalAmount', width : 100,align : "right",sortable:false,
									formatter:function(cellvalue, options, row){
										if(cellvalue == null){
											cellvalue = "0.00";
										}
										return cellvalue;
									}
								},
								{name : 'createUserName',index : 'submitUser', width : 160,align : "center",sortable:false},									
                                {name : 'createDateTime',index : 'submitDatetime', width : 160,align : "center",sortable:false,
									formatter:function(cellvalue, options, row){
										if(cellvalue == null){
											cellvalue = "--";
										}
										return cellvalue;
									}
								}
								
					],
					rownumbers : true,
					pager : "#gridpage",
					viewrecords : true,
					caption : "<spring:message code="message.jieSuan.zhiFuDan"/><spring:message code="message.listForm.lieBiao"/>",
					//序号宽度自动变化
                    gridComplete:function(){
                        //序号列宽度自适应（参数为jqgridID）
                        autoRNWidth("gridlist");
                        //数据只有一条时默认选中（参数为jqgridID）
                        selectByOneData("gridlist");
                    },
					jsonReader : {
						repeatitems : false,
						id : "ids"
					}
				});
		
		
		$("#gridlist").jqGrid('navGrid', '#gridpage', {add : false,edit : false,del : false,search : false,refresh : false});
		$(window).trigger("resize");
    });
    
    function detail(id){
    	$("#settlementId").val(id);
    	$("#settlementFrom").submit();
    }
 </script>
</body>
</html>